package site.yunnong.atvris.portal.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import site.yunnong.atvris.common.api.Page;
import site.yunnong.atvris.common.api.ResultVO;
import site.yunnong.atvris.service.InteractionService;
import site.yunnong.atvris.common.dto.UserFansQueryParam;
import site.yunnong.atvris.common.dto.UserFollowQueryParam;
import site.yunnong.atvris.portal.service.FollowService;
import site.yunnong.atvris.service.vo.UserFansVO;
import site.yunnong.atvris.service.vo.UserFollowVO;

import javax.annotation.Resource;

/**
 * @author JinghaoZhang
 * @date 2021年-04月-07日
 */
@Api(tags = "用户关注管理")
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private FollowService followService;
    @Resource
    private InteractionService interactionService;

    @ApiOperation("关注某个用户")
    @PostMapping("/follow")
    public ResultVO follow(@RequestParam("uuid") Long uuid) {
        interactionService.follow(uuid);
        return new ResultVO().success();
    }

    @ApiOperation("取关某个用户")
    @PostMapping("/unfollow")
    public ResultVO unfollow(@RequestParam("uuid") Long uuid) {
        interactionService.unfollow(uuid);
        return new ResultVO().success();
    }

    @ApiOperation("分页获取用户关注列表")
    @PostMapping("/list") 
    public ResultVO list(@RequestBody UserFollowQueryParam param) {
        Page<UserFollowVO> followVOPage = followService.queryFollowList(param);
        return new ResultVO().success(followVOPage);
    }

    @ApiOperation("分页获取粉丝列表")
    @PostMapping("/fans-list")
    public ResultVO fanslist(@RequestBody UserFansQueryParam param) {
        Page<UserFansVO> fansVOPage = followService.queryFansList(param);
        return new ResultVO().success(fansVOPage);
    }
}
